package comp;
import java.io.File;
import java.io.IOException;
import java.util.*;

import org.dom4j.DocumentException;

import dpdetector.DetectorManager;
import dpdetector.DetectorManager.DetectorEnum;

import recoder.ParserException;
import util.PatternXMLParser;

import entity.Metrics;
import entity.PatternRoleVector;


public class TrainingSetGenerator {
	String inputFilePath;
	Map<String,Metrics> metricsMap;
	Map<String,Set<Enum>> patternMap;
	Map<String,String> trainDataVectorMap;
	List<String> knownPatternFiles;
	String knownPatternRepository;
	
	
	
	public TrainingSetGenerator(Map<String,Metrics> metricsMap,String inputFilePath, 
		Map<String, Set<Enum>> patternMap2){
		this.metricsMap = metricsMap;
		this.inputFilePath = inputFilePath;
		this.patternMap = patternMap2;
		
		trainDataVectorMap = new HashMap<String,String>();
		
	}
	
	
	
	public Map<String,String> getTrainData() {
		
		return trainDataVectorMap;
	}






	public void generateTrainingData() throws IOException, ParserException, ClassNotFoundException, DocumentException{

		joinMetricsWithKnownPattern();
	}
	

	
	private void joinMetricsWithKnownPattern(){

		//join on key
		//name - exact matching
    	for(String name : patternMap.keySet()){
    		if(metricsMap.containsKey(name)){ 			
    			//System.out.println(metricsMap.get(name).toCSV()+" "+PatternRoleVector.getVector(patternMap.get(name)));
    			//I need to store the joined result
    			trainDataVectorMap.put(name,metricsMap.get(name).toCSVWithoutClassNames()+PatternRoleVector.getVector(patternMap.get(name)));
    			
    		}
    	}
	}
	
	
	

}
